home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Secrets 4 / Hacker's Secrets 4.iso / misc / password.txt < prev    next >
Text File  |  1991-06-30  |  22KB  |  596 lines

  1.  
  2.         Password Security: A Case History Encryption
  3.                          Computing
  4.  
  5.  
  6.                        Robert Morris
  7.  
  8.                         Ken Thompson
  9.  
  10.  
  11.  
  12.  
  13.                           ABSTRACT
  14.  
  15.           This  paper  describes  the  history  of  the
  16.      design  of  the  password  security  scheme  on  a
  17.      remotely  accessed   time-sharing   system.    The
  18.      present   design  was  the  result  of  countering
  19.      observed attempts to penetrate  the  system.   The
  20.      result  is  a  compromise between extreme security
  21.      and ease of use.
  22.  
  23.  
  24.  
  25. April 3, 1978
  26.  
  27.  
  28.  
  29.         Password Security: A Case History Encryption
  30.                          Computing
  31.  
  32.  
  33.                        Robert Morris
  34.  
  35.                         Ken Thompson
  36.  
  37.  
  38.  
  39.  
  40.                         INTRODUCTION
  41.  
  42.      Password security on the UNIX time-sharing system  [1]
  43. is  provided by a collection of programs whose elaborate and
  44. strange design is the outgrowth of many years of  experience
  45. with  earlier versions.  To help develop a secure system, we
  46. have had a continuing competition  to  devise  new  ways  to
  47. attack  the security of the system (the bad guy) and, at the
  48. same time, to  devise  new  techniques  to  resist  the  new
  49. attacks  (the  good  guy).  This competition has been in the
  50. same vein  as  the  competition  of  long  standing  between
  51. manufacturers  of  armor  plate  and those of armor-piercing
  52. shells.  For this reason, the description that follows  will
  53. trace  the history of the password system rather than simply
  54. presenting the program in its current state.  In  this  way,
  55. the  reasons  for  the  design  will be made clearer, as the
  56. design cannot be understood without also  understanding  the
  57. potential attacks.
  58.  
  59.      An underlying goal has been to provide  password  secu-
  60. rity  at  minimal  inconvenience to the users of the system.
  61. For example, those who want to run a completely open  system
  62. without  passwords,  or to have passwords only at the option
  63. of the individual users, are able to do so, while those  who
  64. require  all  of  their  users to have passwords gain a high
  65. degree of security against  penetration  of  the  system  by
  66. unauthorized users.
  67.  
  68.      The password system must be able not  only  to  prevent
  69. any access to the system by unauthorized users (i.e. prevent
  70. them from logging in at all), but it must also prevent users
  71. who  are  already  logged in from doing things that they are
  72. not authorized to do.  The so  called  ``super-user''  pass-
  73. word,  for  example,  is  especially  critical  because  the
  74. super-user has all sorts of permissions and has  essentially
  75. unlimited access to all system resources.
  76.  
  77. _________________________
  78. |- UNIX is a trademark of Bell Laboratories.
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.                            - 2 -
  90.  
  91.  
  92.      Password security is of course only  one  component  of
  93. overall  system  security, but it is an essential component.
  94. Experience has shown  that  attempts  to  penetrate  remote-
  95. access systems have been astonishingly sophisticated.
  96.  
  97.      Remote-access  systems  are  peculiarly  vulnerable  to
  98. penetration  by outsiders as there are threats at the remote
  99. terminal, along the communications link, as well as  at  the
  100. computer  itself.   Although  the  security  of  a  password
  101. encryption algorithm  is  an  interesting  intellectual  and
  102. mathematical  problem,  it  is only one tiny facet of a very
  103. large problem.  In practice, physical security of  the  com-
  104. puter,  communications  security of the communications link,
  105. and physical control of the computer itself loom as far more
  106. important  issues.  Perhaps most important of all is control
  107. over the actions of ex-employees, since they are  not  under
  108. any  direct  control  and  they  may have intimate knowledge
  109. about the system, its  resources,  and  methods  of  access.
  110. Good  system  security  involves realistic evaluation of the
  111. risks not only of deliberate  attacks  but  also  of  casual
  112. unauthorized access and accidental disclosure.
  113.  
  114. PROLOGUE
  115.  
  116.      The UNIX system was first implemented with  a  password
  117. file  that  contained the actual passwords of all the users,
  118. and for that reason the password file had to be heavily pro-
  119. tected  against being either read or written.  Although his-
  120. torically, this had been  the  technique  used  for  remote-
  121. access systems, it was completely unsatisfactory for several
  122. reasons.
  123.  
  124.      The technique is excessively vulnerable  to  lapses  in
  125. security.   Temporary  loss of protection can occur when the
  126. password file is being edited or otherwise modified.   There
  127. is  no  way  to  prevent  the making of copies by privileged
  128. users.  Experience with several earlier  remote-access  sys-
  129. tems  showed  that  such  lapses occur with frightening fre-
  130. quency.  Perhaps the most memorable such  occasion  occurred
  131. in  the  early  60's when a system administrator on the CTSS
  132. system at MIT was editing the password file and another sys-
  133. tem  administrator  was  editing  the  daily message that is
  134. printed on everyone's terminal on login.  Due to a  software
  135. design  error,  the  temporary editor files of the two users
  136. were interchanged and thus, for a time,  the  password  file
  137. was printed on every terminal when it was logged in.
  138.  
  139.      Once such a lapse  in  security  has  been  discovered,
  140. everyone's password must be changed, usually simultaneously,
  141. at a considerable administrative cost.  This is not a  great
  142. matter, but far more serious is the high probability of such
  143. lapses going unnoticed by the system administrators.
  144.  
  145.      Security  against  unauthorized   disclosure   of   the
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.                            - 3 -
  156.  
  157.  
  158. passwords  was,  in  the last analysis, impossible with this
  159. system because, for example, if the  contents  of  the  file
  160. system  are put on to magnetic tape for backup, as they must
  161. be, then anyone who has physical access to the tape can read
  162. anything on it with no restriction.
  163.  
  164.      Many programs must get  information  of  various  kinds
  165. about the users of the system, and these programs in general
  166. should have no special permission to read the password file.
  167. The  information which should have been in the password file
  168. actually was distributed (or replicated) into  a  number  of
  169. files,  all  of  which had to be updated whenever a user was
  170. added to or dropped from the system.
  171.  
  172. THE FIRST SCHEME
  173.  
  174.      The obvious solution is to arrange that  the  passwords
  175. not  appear in the system at all, and it is not difficult to
  176. decide that this can be done by encrypting each user's pass-
  177. word,  putting only the encrypted form in the password file,
  178. and throwing away his original password  (the  one  that  he
  179. typed  in).  When the user later tries to log in to the sys-
  180. tem, the password that he types is  encrypted  and  compared
  181. with the encrypted version in the password file.  If the two
  182. match, his login attempt is accepted.   Such  a  scheme  was
  183. first  described  in [3, p.91ff.].  It also seemed advisable
  184. to devise a system in which neither the  password  file  nor
  185. the  password  program itself needed to be protected against
  186. being read by anyone.
  187.  
  188.      All that was needed to implement  these  ideas  was  to
  189. find  a  means  of  encryption  that  was  very difficult to
  190. invert, even when the encryption program is available.  Most
  191. of  the  standard  encryption methods used (in the past) for
  192. encryption of messages are rather easy to  invert.   A  con-
  193. venient and rather good encryption program happened to exist
  194. on the system at the time; it  simulated  the  M-209  cipher
  195. machine  [4]  used by the U.S. Army during World War II.  It
  196. turned out that the M-209 program was  usable,  but  with  a
  197. given  key, the ciphers produced by this program are trivial
  198. to invert.  It is a much more difficult matter to  find  out
  199. the  key given the cleartext input and the enciphered output
  200. of the program.  Therefore, the password was used not as the
  201. text  to  be  encrypted  but  as the key, and a constant was
  202. encrypted using this key.  The encrypted result was  entered
  203. into the password file.
  204.  
  205. ATTACKS ON THE FIRST APPROACH
  206.  
  207.      Suppose that the bad guy has available the text of  the
  208. password  encryption program and the complete password file.
  209. Suppose also that he has substantial computing  capacity  at
  210. his disposal.
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.                            - 4 -
  222.  
  223.  
  224.      One  obvious  approach  to  penetrating  the   password
  225. mechanism  is to attempt to find a general method of invert-
  226. ing the encryption algorithm.  Very  possibly  this  can  be
  227. done, but few successful results have come to light, despite
  228. substantial efforts extending over a  period  of  more  than
  229. five  years.   The results have not proved to be very useful
  230. in penetrating systems.
  231.  
  232.      Another approach to penetration is simply to keep  try-
  233. ing  potential  passwords until one succeeds; this is a gen-
  234. eral cryptanalytic approach called key search.  Human beings
  235. being  what  they are, there is a strong tendency for people
  236. to choose relatively short and simple  passwords  that  they
  237. can  remember.   Given  free choice, most people will choose
  238. their passwords from a restricted character  set  (e.g.  all
  239. lower-case  letters),  and will often choose words or names.
  240. This human habit makes the  key  search  job  a  great  deal
  241. easier.
  242.  
  243.      The critical factor  involved  in  key  search  is  the
  244. amount of time needed to encrypt a potential password and to
  245. check the result against an entry in the password file.  The
  246. running  time  to  encrypt  one trial password and check the
  247. result turned out to be approximately 1.25 milliseconds on a
  248. PDP-11/70 when the encryption algorithm was recoded for max-
  249. imum speed.  It is takes essentially no more  time  to  test
  250. the encrypted trial password against all the passwords in an
  251. entire password file, or for that matter, against  any  col-
  252. lection  of encrypted passwords, perhaps collected from many
  253. installations.
  254.  
  255.      If we want to check all passwords of length n that con-
  256. sist  entirely  of  lower-case  letters,  the number of such
  257. passwords is $26 sup n$.  If we suppose  that  the  password
  258. consists  of  printable  characters only, then the number of
  259. possible passwords is somewhat less than $95 sup  n$.   (The
  260. standard  system ``character erase'' and ``line kill'' char-
  261. acters are, for  example,  not  prime  candidates.)  We  can
  262. immediately estimate the running time of a program that will
  263. test every password of a given length with all of its  char-
  264. acters  chosen  from  some set of characters.  The following
  265. table gives estimates of the  running  time  required  on  a
  266. PDP-11/70  to  test all possible character strings of length
  267. $n$ chosen from various  sets  of  characters:  namely,  all
  268. lower-case  letters, all lower-case letters plus digits, all
  269. alphanumeric characters, all 95 printable ASCII  characters,
  270. and finally all 128 ASCII characters.
  271.  
  272.  
  273.  
  274.                            - 5 -
  275.  
  276.  
  277. One has to conclude that it is no great matter  for  someone
  278. with  access  to  a PDP-11 to test all lower-case alphabetic
  279. strings up to length five and, given access to  the  machine
  280. for,  say,  several weekends, to test all such strings up to
  281. six characters in length.  By using such a program against a
  282. collection  of  actual  encrypted  passwords,  a substantial
  283. fraction of all the passwords will be found.
  284.  
  285.      Another profitable approach for the bad guy is  to  use
  286. the  word  list from a dictionary or to use a list of names.
  287. For example, a large commercial  dictionary  contains  typi-
  288. callly  about  250,000  words; these words can be checked in
  289. about five minutes.  Again, a  noticeable  fraction  of  any
  290. collection  of  passwords  will  be found.  Improvements and
  291. extensions will be (and have been) found by a determined bad
  292. guy.  Some ``good'' things to try are:
  293.  
  294. -    The dictionary with the words spelled backwards.
  295.  
  296. -    A list of first names (best obtained from some  mailing
  297.      list).   Last  names, street names, and city names also
  298.      work well.
  299.  
  300. -    The above with initial upper-case letters.
  301.  
  302. -    All valid license plate numbers in your  state.   (This
  303.      takes about five hours in New Jersey.)
  304.  
  305. -    Room  numbers,  social  security   numbers,   telephone
  306.      numbers, and the like.
  307.  
  308.      The authors have conducted experiments to try to deter-
  309. mine  typical  users' habits in the choice of passwords when
  310. no constraint is put on  their  choice.   The  results  were
  311. disappointing,  except  to  the bad guy.  In a collection of
  312. 3,289 passwords gathered from many users over a long  period
  313. of time;
  314.  
  315.      15 were a single ASCII character;
  316.  
  317.      72 were strings of two ASCII characters;
  318.  
  319.      464 were strings of three ASCII characters;
  320.  
  321.      477 were string of four alphamerics;
  322.  
  323.      706 were five letters, all  upper-case  or  all  lower-
  324.      case;
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.                            - 6 -
  336.  
  337.  
  338.      605 were six letters, all lower-case.
  339.  
  340. An additional 492 passwords appeared  in  various  available
  341. dictionaries,  name  lists, and the like.  A total of 2,831,
  342. or 86% of this sample of passwords fell into  one  of  these
  343. classes.
  344.  
  345.      There was, of course, considerable overlap between  the
  346. dictionary  results  and the character string searches.  The
  347. dictionary search alone, which required only five minutes to
  348. run, produced about one third of the passwords.
  349.  
  350.      Users could be urged (or forced) to use  either  longer
  351. passwords  or  passwords chosen from a larger character set,
  352. or the system could itself choose passwords for the users.
  353.  
  354. AN ANECDOTE
  355.  
  356.      An entertaining and instructive example is the  attempt
  357. made at one installation to force users to use less predict-
  358. able passwords.  The users did not choose  their  own  pass-
  359. words;  the  system  supplied  them.  The supplied passwords
  360. were eight characters long and were taken from the character
  361. set  consisting of lower-case letters and digits.  They were
  362. generated by a pseudo-random number generator with  only  $2
  363. sup 15$ starting values.  The time required to search (again
  364. on a PDP-11/70) through all character strings  of  length  8
  365. from a 36-character alphabet is 112 years.
  366.  
  367.      Unfortunately, only $2 sup 15$ of them need  be  looked
  368. at,  because  that  is the number of possible outputs of the
  369. random number generator.  The bad guy did, in fact, generate
  370. and  test  each  of these strings and found every one of the
  371. system-generated passwords using a total of only  about  one
  372. minute of machine time.
  373.  
  374. IMPROVEMENTS TO THE FIRST APPROACH
  375.  
  376. 1.  Slower Encryption
  377.  
  378.      Obviously, the first algorithm used was far  too  fast.
  379. The  announcement of the DES encryption algorithm [2] by the
  380. National Bureau of Standards was timely and fortunate.   The
  381. DES  is,  by design, hard to invert, but equally valuable is
  382. the fact that it  is  extremely  slow  when  implemented  in
  383. software.  The DES was implemented and used in the following
  384. way: The first eight characters of the user's  password  are
  385. used  as  a  key  for the DES; then the algorithm is used to
  386. encrypt a constant.  Although this constant is zero  at  the
  387. moment,   it   is   easily   accessible   and  can  be  made
  388. installation-dependent.  Then the DES algorithm is  iterated
  389. 25  times and the resulting 64 bits are repacked to become a
  390. string of 11 printable characters.
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.                            - 7 -
  402.  
  403.  
  404. 2.  Less Predictable Passwords
  405.  
  406.      The password entry program was modified so as  to  urge
  407. the  user to use more obscure passwords.  If the user enters
  408. an alphabetic password (all upper-case  or  all  lower-case)
  409. shorter  than  six  characters,  or a password from a larger
  410. character set shorter than five characters, then the program
  411. asks  him  to enter a longer password.  This further reduces
  412. the efficacy of key search.
  413.  
  414.      These improvements make  it  exceedingly  difficult  to
  415. find  any  individual  password.   The user is warned of the
  416. risks and if he cooperates, he is very safe indeed.  On  the
  417. other hand, he is not prevented from using his spouse's name
  418. if he wants to.
  419.  
  420. 3.  Salted Passwords
  421.  
  422.      The key search technique is still likely to turn  up  a
  423. few passwords when it is used on a large collection of pass-
  424. words, and it seemed wise to make this task as difficult  as
  425. possible.   To  this  end, when a password is first entered,
  426. the password program obtains  a  12-bit  random  number  (by
  427. reading  the  real-time clock) and appends this to the pass-
  428. word typed in by  the  user.   The  concatenated  string  is
  429. encrypted  and  both  the 12-bit random quantity (called the
  430. $salt$) and the 64-bit result of the encryption are  entered
  431. into the password file.
  432.  
  433.      When the user later logs in to the system,  the  12-bit
  434. quantity is extracted from the password file and appended to
  435. the typed password.  The encrypted result  is  required,  as
  436. before, to be the same as the remaining 64 bits in the pass-
  437. word file.  This modification does not increase the task  of
  438. finding  any individual password, starting from scratch, but
  439. now the work of testing a given character string  against  a
  440. large  collection of encrypted passwords has been multiplied
  441. by 4096 ($2 sup 12$).  The reason for this is that there are
  442. 4096 encrypted versions of each password and one of them has
  443. been picked more or less at random by the system.
  444.  
  445.      With this modification, it is likely that the  bad  guy
  446. can spend days of computer time trying to find a password on
  447. a system with hundreds of passwords, and find none  at  all.
  448. More  important  is  the fact that it becomes impractical to
  449. prepare  an  encrypted  dictionary  in  advance.   Such   an
  450. encrypted dictionary could be used to crack new passwords in
  451. milliseconds when they appear.
  452.  
  453.      There is a (not inadvertent) side effect of this modif-
  454. ication.  It becomes nearly impossible to find out whether a
  455. person with passwords on two or more systems  has  used  the
  456. same password on all of them, unless you already know that.
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.                            - 8 -
  468.  
  469.  
  470. 4.  The Threat of the DES Chip
  471.  
  472.      Chips to perform the DES encryption are already commer-
  473. cially  available and they are very fast.  The use of such a
  474. chip speeds up the process of password hunting by three ord-
  475. ers  of  magnitude.   To  avert this possibility, one of the
  476. internal tables of the DES  algorithm  (in  particular,  the
  477. so-called  E-table)  is changed in a way that depends on the
  478. 12-bit random number.  The E-table is inseparably wired into
  479. the  DES  chip,  so that the commercial chip cannot be used.
  480. Obviously, the bad guy could have his own chip designed  and
  481. built, but the cost would be unthinkable.
  482.  
  483. 5.  A Subtle Point
  484.  
  485.      To login successfully on the UNIX system, it is  neces-
  486. sary  after  dialing  in to type a valid user name, and then
  487. the correct password for that user name.  It is poor  design
  488. to  write  the  login command in such a way that it tells an
  489. interloper when he has typed in a invalid  user  name.   The
  490. response  to an invalid name should be identical to that for
  491. a valid name.
  492.  
  493.      When the slow encryption  algorithm  was  first  imple-
  494. mented,  the  encryption  was done only if the user name was
  495. valid, because otherwise there was no encrypted password  to
  496. compare with the supplied password.  The result was that the
  497. response was delayed by about one-half second  if  the  name
  498. was  valid, but was immediate if invalid.  The bad guy could
  499. find out whether a particular user name was valid.  The rou-
  500. tine was modified to do the encryption in either case.
  501.  
  502. CONCLUSIONS
  503.  
  504.      On the issue of password  security,  UNIX  is  probably
  505. better  than  most  systems.  The use of encrypted passwords
  506. appears reasonably secure in the absence of  serious  atten-
  507. tion of experts in the field.
  508.  
  509.      It is also  worth  some  effort  to  conceal  even  the
  510. encrypted passwords.  Some UNIX systems have instituted what
  511. is called an ``external security code'' that must  be  typed
  512. when  dialing  into  the  system, but before logging in.  If
  513. this code is changed periodically, then someone with an  old
  514. password will likely be prevented from using it.
  515.  
  516.      Whenever any  security  procedure  is  instituted  that
  517. attempts  to deny access to unauthorized persons, it is wise
  518. to  keep  a  record  of  both  successful  and  unsuccessful
  519. attempts  to  get  at the secured resource.  Just as an out-
  520. of-hours visitor to a computer center normally must not only
  521. identify  himself,  but a record is usually also kept of his
  522. entry.  Just so, it is a wise precaution to make and keep  a
  523. record  of  all  attempts  to log into a remote-access time-
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.                            - 9 -
  534.  
  535.  
  536. sharing system, and certainly all unsuccessful attempts.
  537.  
  538.      Bad guys fall on a spectrum whose one  end  is  someone
  539. with  ordinary  access to a system and whose goal is to find
  540. out a particular password (usually that of  the  super-user)
  541. and, at the other end, someone who wishes to collect as much
  542. password information as possible from  as  many  systems  as
  543. possible.   Most  of  the work reported here serves to frus-
  544. trate the latter type; our  experience  indicates  that  the
  545. former type of bad guy never was very successful.
  546.  
  547.      We recognize that a time-sharing system must operate in
  548. a hostile environment.  We did not attempt to hide the secu-
  549. rity aspects of the operating system,  thereby  playing  the
  550. customary  make-believe game in which weaknesses of the sys-
  551. tem are not discussed no matter  how  apparent.   Rather  we
  552. advertised  the password algorithm and invited attack in the
  553. belief that this approach  would  minimize  future  trouble.
  554. The approach has been successful.
  555.  
  556. References
  557.  
  558. [1]  Ritchie, D.M. and Thompson, K.  The  UNIX  Time-Sharing
  559.      System.  Comm. ACM 17 (July 1974), pp. 365-375.
  560.  
  561. [2]  Proposed Federal Information Processing Data Encryption
  562.      Standard.  Federal Register (40FR12134), March 17, 1975
  563.  
  564. [3]  Wilkes, M. V.  Time-Sharing Computer Systems.  American
  565.      Elsevier, New York, (1968).
  566.  
  567. [4]  U. S. Patent Number 2,089,603.
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.